package com.skt.domain.ENUM;

import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;

@Getter
public enum UserRoleStatus implements IEnum<Integer> {
    PENDING(0, "待审核"),
    APPROVED(1, "已通过"),
    REJECTED(2, "已拒绝");

    private final int code;
    private final String desc;

    UserRoleStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return this.code;
    }

    // ✅ 支持 Byte / Integer / Short 等
    public static UserRoleStatus fromCode(Number code) {
        if (code == null) return null;
        int val = code.intValue();
        for (UserRoleStatus status : values()) {
            if (status.code == val) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的 UserRoleStatus code: " + code);
    }
}